﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>加盟套餐设置-新增套餐</title> <#include "../common/Resources.ftl"/>

</head>
<body>
	<div id="mainWraper" class="clearfix">
		<div class="edit-box borker-edit-box">
			<div class="edit-box-hd">
				<div class="tool">
					<div class="fl">
						<a class="mini-button " href="${ctx}/joinPackage/manager"><span
							class="mini-button-text">返回</span> </a>
					</div>
					<div class="fr">
						<div class="breadCrumb">您的位置：<a href="${ctx}/joinPackage/manager">加盟套餐设置</a> &gt; <span class="current">新增加盟套餐</span></div>
					</div>
				</div>
			</div>
			<div class="edit-box-bd">
				<div class="form-box">
					<table width="" border="0" cellspacing="0" cellpadding="0"
						class="form-table form-table-towcols">
						<tr>
							<th align="right">城市：</th>
							<td>
							<div class="f7"  title="选择城市">
			                	<input type="text" name="limitCityName" id="limitCityName" 
							    class="input-text IDcard" reg='Required' tip="请选择城市" readonly="readonly"/>
								<input type="hidden" name="limitCity" id="limitCity"/>	
									<a class="f7-select" onclick="onclickOrg()"></a>
				        	</div>
							</td>
						</tr>
							<tr>
							<th align="right" scope="col">套餐类型：</th>
							<td scope="col">
							<#if joinTypeEnum??>
							 <#list joinTypeEnum as joinType>
							 
							 <input type="radio" name="type"  <#if joinType.value=="ALL_CAPITAL"> checked="checked" </#if>  
							 id="type" value="${joinType.value?if_exists}"/>${joinType.name?if_exists}
							 </#list> 
							</#if>
							 </td>
						</tr>
						<tr>
							<th align="right" scope="col">套餐名称：</th>
							<td scope="col"><input type="text" name="name" id="name"
								class="input-text" reg='Required' tip="请输入名称" /></td>
						</tr>
						<tr>
							<th align="right">合同期限：</th>
							<td><label> <input type="text" name="usePeriod"
									id="usePeriod" class="input-text" reg='number' maxNumber="10" tip="请输入数字" />月
							</label>
							</td>
						</tr>
						<tr>
							<th align="right">赠送时间：</th>
							<td><input type="text" name="freePeriod"
								id="freePeriod" class="input-text" reg='number' maxNumber="10" tip="请输入数字" />月</td>
						</tr>
						<tr>
							<th align="right">合同金额：</th>
							<td><input type="text" name="packagePrice" id="packagePrice"
								class="input-text IDcard" reg='Float' maxNumber="10" tip="请输入数字" />元
							</td>
						</tr>
						<tr>
							<th align="right">默认折扣率：</th>
							<td><input type="text" name="discountRatio"
								id="discountRatio" class="input-text blongStore" reg='Float' 
								tip="请输入数字" />%</td>
						</tr>
						<tr>
							<th align="right">保证金：</th>
							<td><input type="text" name="ensurePrice" id="ensurePrice" maxNumber="10"
								class="input-text IDcard" reg='Float' tip="请输入数字" /> 元</td>
						</tr>                        
						<tr>
							<th align="right">&nbsp;</th>
							<td>
								<div class="form-button">
									<a class="mini-button importantBtn"
										href="javascript:toSubmit();"><span
										class="mini-button-text">保存</span>
									</a>
								</div></td>

						</tr>
					</table>
				</div>
			</div>

		</div>
	</div>
	<!--右边结束 -->
</body>
<script type="text/javascript" src="${base}/scripts/plugin/easy_validator.pack.js"></script>
<script>
	function onclickOrg(){
			art.dialog.data("returnFunName","selectOrg");
			art.dialog.open(ctx+'/f7/index/getErpOrg',{title: '城市选择', lock: true,  skin: 'aero',padding:0,width:450,height:365});
	}

	function toSubmit() {		
		if($("#discountRatio").val()>100){
			art.dialog.alert("折扣率不能大于100");
			$("#discountRatio").focus();
			return ;
		}
		var joinPackage={};
		joinPackage.name= $("#name").val(),
		joinPackage.type= $('input[name=type]:checked').val(),
		joinPackage.limitCity= $("#limitCity").val(),
		joinPackage.discountRatio= $("#discountRatio").val(),
		joinPackage.ensurePrice= $("#ensurePrice").val(),
		joinPackage.packagePrice= $("#packagePrice").val(),
		joinPackage.freePeriod= $("#freePeriod").val(),
		joinPackage.usePeriod= $("#usePeriod").val()
		if(validateForm($("#mainWraper"))){
		$.ajax({
			url : ctx + '/joinPackage/save',
			dataType : 'json',
			type : 'post',
			data : joinPackage,
			success : function(data) {
				if (data.message == "1") {					
					art.dialog.optTips('保存成功',3,"success");
					location.href= ctx + '/joinPackage/manager';
				} else {
					art.dialog.optTips('保存失败',3,"failure");
				}
			}
		});
		}
	}
	function selectOrg(obj) {
		$("#limitCity").val(obj.id)
		$("#limitCityName").val(obj.name)
	}
</script>
</html>
